package com.alog.storage.net;

import android.content.Context;
import com.alog.storage.Contants;
import com.alog.storage.domain.ResponseInfo;

/**
 * 账户API类
 */
public class AccountAPI extends BaseAPI {
    private final String URL_LOGIN = Contants.BASE_URL + "/";

    public <T> AccountAPI(Context context, APICallback<T> callback) {
        super(context, callback);
    }

    /**
     * 登录
     */
    public void login(int apiId, String username, String pwd) {
        requestData(apiId, URL_LOGIN, genLoginBody(username, pwd));
    }

    private byte[] genLoginBody(String username, String pwd) {
        //生成body数据，并加密
        return encrypt(null);
    }

    @Override
    protected <T> T parseData(ResponseInfo info) throws Exception {
        switch (info.apiId) {
            case Contants.API_ID_LOGIN:
                parseLoginInfo(info.data);
        }
        return null;
    }

    private void parseLoginInfo(byte[] data) {
        if (data != null) {
            //解析登录后的数据并保存
        }
    }

}
